

<?php require_once ADMINVIEWPATH.'admin_header.php'; ?>
<?php require_once ADMINVIEWPATH.'admin_menu.php'; ?>
<!-- Page Content -->
            <div class="page-content">
                <!-- Page Breadcrumb -->
                <div class="page-breadcrumbs">
                    <ul class="breadcrumb">
                        <li>
                            <i class="fa fa-home"></i>
                            <a href="/luckydog/index">首页</a>
                        </li>
                        <li class="active">
                            <a href="#">角色管理</a>
                        </li>
                        <li class="active">角色列表</li>
                    </ul>
                </div>
                <div class="page-body">
                    <div class="row">
                        <div class="col-xs-12 col-md-12">
                            <div class="tab-content tabs-flat no-padding">
                                <div id="visits" class="tab-pane active animated fadeInUp">
                                    <div class="row">
                                        <div class="col-lg-12 chart-container">
                                            <div id="dashboard-chart-visits" class="chart chart-lg no-margin">
                                                <div class="widget-body">
                                                        <div class="table-toolbar">
                                                            <?php if(check_authorize("System","Role","add")):?>
                                                            <a id="editabledatatable_new" href="/luckydog/role/toRolePower"  class="btn btn-default">
                                                                添加角色
                                                            </a>
                                                            <?php endif;?>
                                                        </div>
                                                        <table class="table table-striped table-bordered table-hover" id="simpledatatable">
                                                            <thead>
                                                                <tr>
                                                                <th>序号</th>
                                                                <th>角色</th>
                                                                <th width="50%">权限清单</th>
                                                                <th>状态</th>
                                                                <th>操作</th>
                                                            </tr>
                                                            </thead>
                                                            <tbody>
                                                            
                                                               <?php if(!empty($role_list)):?>
                                                                    <?php foreach($role_list as $key=> $row):?>
                                                                        <tr class="gradeX ">
                                                                            <td class="center" style="text-align:center;width:40px;"><?php echo $key+1;?></td>
                                                                            <td class="center"><?php echo $row['name']?></td>
                                                                            <td class="center">
                                                                            <?php foreach($row['rolePower'] as $value):?>
                                                                               <?=$value['describe']."、"?>
                                                                            <?php endforeach;?>
                                                                            </td>
                                                                            <td class="center"><?php if($row['status'] == 1){echo "启用";}else{echo "禁用";}?></td>
                                                                            <td class="center " data_id = "<?php echo $row['id'];?>">
                                                                                <?php if(check_authorize("System","Role","edit")):?>
                                                                                <a href="/luckydog/role/toRolePower?gropuID=<?=$row['id']?>" class="edit_role">设置</a>&nbsp;|&nbsp;
                                                                                <?php endif;?>
                                                                                <?php if(check_authorize("System","Role","delete")):?>
                                                                                <a href="javascript:;" class="J_del">删除</a>&nbsp;|&nbsp;
                                                                                <?php endif;?>
                                                                                <?php if(check_authorize("System","Role","forbid")):?>
                                                                                <a href="javascript:;" class="J_Setstatus" status="<?php echo $row['status']?>"><?php if($row['status'] != 1){echo "启用";}else{echo "禁用";}?></a>
                                                                                <?php endif;?>
                                                                            </td>
                                                                        </tr>
                                                                    <?php endforeach;?>
                                                                <?php endif;?>
                                                                <tr>
                                                                    <td align='center' colspan="7"></td>
                                                                </tr>
                                                               
                                                            </tbody>
                                                        </table>
                                                    </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /Page Body -->
        </div>
        <!-- /Page Content -->
<script src="<?php echo STATICURL; ?>js/jquery-2.0.3.min.js"></script>
<script src="<?php echo STATICURL; ?>layer/layer.js"></script>
<?php require_once ADMINVIEWPATH.'admin_footer.php'; ?>
<script>
    $(document).ready(function() {
        $(".J_del").click(function() {
            var id = $(this).parent().attr("data_id");
            if (confirm("您确定要删除该角色吗？")) {
                $.post("/luckydog/role/delRole", {"id":id}, function(res) {
                    if (res) {
                        window.location.reload();
                    }else{
                        alert("删除失败");
                    }
                });
            }
        });

        $(".J_Setstatus").click(function() {
            var id = $(this).parent().attr("data_id");
            var status = $(this).attr("status");
            if(status == 1){
                status = -1;
            }else{
                status = 1;
            }
            $.post("/luckydog/role/setStatus", {"id":id,"status":status}, function(res) {
                if (res) {
                    window.location.reload();
                }else{
                    alert("失败");
                }
            });
        });
    });

</script>





